home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume4 / nrtable < prev    next >
Encoding:
Internet Message Format  |  1986-11-30  |  45.0 KB

  1. From: genrad!linus!utzoo!bnr-vpa!bruce (Bruce Townsend)
  2. Subject: compile/decompile nroff driver tables (USG only)
  3. Newsgroups: mod.sources
  4. Approved: jpn@panda.UUCP
  5.  
  6. Mod.sources:  Volume 4, Issue 48
  7. Submitted by: utzoo!bnr-vpa!bruce (Bruce Townsend)
  8.  
  9.     This program is intended for USG systems only, since
  10. Berkelely has a different driver table format, and I understand
  11. that many (all?) Berkeley systems have the necessary tools
  12. supplied.
  13.     My submission includes a program for building tables
  14. from a source, a man page (term.5) explaining the source, a
  15. program that does the inverse operation of building a source
  16. from existing binary tables (useful for modifying existing
  17. tables) and various bits of documentation.
  18.     The program is not guaranteed to be portable to all
  19. USG systems, as I did not have access to any other than my own,
  20. but it does run on at least two other machines, and it should
  21. not be too much work to port to any USG machine.
  22.  
  23.  
  24. Following is the shar archive of the source.
  25.  
  26.             Thanks,
  27.             -Bruce Townsend
  28. Mail path: {utzoo, utcs}!bnr-vpa!bruce
  29.  
  30. :----------------------CUT HERE--------------------------
  31. #!/bin/sh
  32. # This is a shell archive, meaning:
  33. # 1. Remove everything above the #!/bin/sh line.
  34. # 2. Save the resulting text in a file.
  35. # 3. Execute the file with /bin/sh (not csh) to create the files:
  36. #    Makefile
  37. #    README
  38. #    charlist
  39. #    elbat.c
  40. #    tabXXX.c
  41. #    table.c
  42. #    table.doc
  43. #    term.5
  44. #    term.h
  45. # This archive created: Mon Jul 29 15:48:02 1985
  46. export PATH; PATH=/bin:$PATH
  47. echo shar: extracting "'Makefile'" '(748 characters)'
  48. if test -f 'Makefile'
  49. then
  50.     echo shar: over-writing existing file "'Makefile'"
  51. fi
  52. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  53. X#    Makefile for table.c, method of producing a single terminal
  54. X#    table for nroff under USG UNIX.
  55. X#    Makefile written by Bruce Townsend (utcs!bnr-vpa!bruce)
  56. X#    and Ian Darwin (utcs!darwin!ian)
  57. X#    March 6, 1985.
  58. X
  59. XTABFILES = tabXXX
  60. XDESTDIR = /usr/lib/term
  61. XLINTTAB = tabXXX
  62. XDEFS =
  63. XCFLAGS = $(DEFS) -O
  64. XLDFLAGS = -s
  65. XLFLAGS = $(DEFS)
  66. X
  67. X$(TABFILES): dummy_file
  68. X    $(MAKE) -$(MAKEFLAGS) table.o $@.o
  69. X    cc $(LDFLAGS) table.o $@.o
  70. X    ./a.out $@
  71. X
  72. X# This dummy_file should never exist, it is a kludge to get Make to
  73. X# always execute cc.
  74. Xdummy_file:
  75. X    @rm -f dummy_file
  76. X
  77. Xall:    $(TABFILES)
  78. X
  79. Xinstall: $(TABFILES)
  80. X    mv $(TABFILES) $(DESTDIR)
  81. X
  82. Xlint:    table.c
  83. X    lint $(LFLAGS) table.c $(LINTTAB).c
  84. X
  85. Xelbat:    elbat.o
  86. X    cc $(LDFLAGS) elbat.o -o elbat
  87. X
  88. Xclean:
  89. X    rm -f a.out tab*.o elbat.o
  90. SHAR_EOF
  91. if test 748 -ne "`wc -c 'Makefile'`"
  92. then
  93.     echo shar: error transmitting "'Makefile'" '(should have been 748 characters)'
  94. fi
  95. echo shar: extracting "'README'" '(1970 characters)'
  96. if test -f 'README'
  97. then
  98.     echo shar: over-writing existing file "'README'"
  99. fi
  100. sed 's/^X//' << \SHAR_EOF > 'README'
  101. X    There are two programs in this package. "table", written by
  102. XBruce Townsend with help from Ian Darwin, prepares an nroff driver
  103. Xtable from a source file. "elbat", written by Matt Crawford and
  104. Xmodified for USG UNIX by Bruce Townsend, is the inverse operation -
  105. Xit decompiles an nroff driver table, producing a source file.
  106. X
  107. X    The Makefile should not need modification other than to
  108. Xadd new names of terminal drivers, of the form "tabXXX" where
  109. X"XXX" is a mnemonic for a terminal, e.g. tab450 for a Diablo 450
  110. Xin 10-pitch mode. These names are added to the TABFILES definition
  111. Xin the Makefile. The format for Berkeley tab files is different
  112. Xand thus this package will not work on Berkely systems without
  113. Xsubstantial hacking.
  114. X
  115. X    You may want to change CFLAGS, LDFLAGS, etc. to your taste
  116. Xor de-bugging preference.
  117. X
  118. X    To compile the elbat program, type "make elbat".
  119. XTo de-compile a file, type "elbat /usr/lib/term/tabXXX > tabXXX.c"
  120. X
  121. X    To compile a tabXXX file (say tab450), type "make tab450".
  122. XOf course, you need the tab450.c source before you do this.
  123. XDo NOT FORGET to include the tabXXX name in the TABFILES definition
  124. Xin the Makefile first.
  125. X
  126. X    Be VERY CAREFULL with "make install" (try "make -n install
  127. Xfirst).
  128. X
  129. X    Read the table.doc file and the term.5 man page for more info.
  130. XI have updated the term.5 man page to reflect this program.
  131. X
  132. XIF YOU HAVE PROBLEMS...
  133. X    It is quite possible that some or all of the integers stored
  134. Xin the tabfile are long, not int. On our machine, long = int = 32 bits,
  135. Xso I do not know which is appropriate. Read the table.doc file for
  136. Xmore info.
  137. X
  138. XAcknowledgements:
  139. X    Ian Darwin tested out the first (very buggy) version of
  140. Xthis utility, and suggested many useful changes, including the
  141. Xintroduction of the Makefile.
  142. X
  143. X    Matt Crawford wrote the elbat program originally for
  144. XBerkeley systems.
  145. X            -Bruce Townsend
  146. X
  147. X            Voice Processing Applications,
  148. X            Bell-Northern Research,
  149. X            Ottawa, Ontario.
  150. X
  151. XMail path: {utzoo, utcs, bnr-di, bnr-mtl}!bnr-vpa!bruce
  152. SHAR_EOF
  153. if test 1970 -ne "`wc -c 'README'`"
  154. then
  155.     echo shar: error transmitting "'README'" '(should have been 1970 characters)'
  156. fi
  157. echo shar: extracting "'charlist'" '(2694 characters)'
  158. if test -f 'charlist'
  159. then
  160.     echo shar: over-writing existing file "'charlist'"
  161. fi
  162. sed 's/^X//' << \SHAR_EOF > 'charlist'
  163. XTABLE OF NROFF CHARACTER INPUT NAMES
  164. XIN THE ORDER THEY APPEAR IN THE codetab[] TABLE
  165. X(see term(5))
  166. X_______________
  167. XName    Number
  168. X        (Octal)
  169. X_______________
  170. X<sp>    000
  171. X!       001
  172. X"       002
  173. X#       003
  174. X$       004
  175. X%       005
  176. X&       006
  177. X'       007
  178. X(       010
  179. X)       011
  180. X*       012
  181. X+       013
  182. X,       014
  183. X-       015
  184. X.       016
  185. X/       017
  186. X0       020
  187. X1       021
  188. X2       022
  189. X3       023
  190. X4       024
  191. X5       025
  192. X6       026
  193. X7       027
  194. X8       030
  195. X9       031
  196. X:       032
  197. X;       033
  198. X<       034
  199. X=       035
  200. X>       036
  201. X?       037
  202. X@       040
  203. XA       041
  204. XB       042
  205. XC       043
  206. XD       044
  207. XE       045
  208. XF       046
  209. XG       047
  210. XH       050
  211. XI       051
  212. XJ       052
  213. XK       053
  214. XL       054
  215. XM       055
  216. XN       056
  217. XO       057
  218. XP       060
  219. XQ       061
  220. XR       062
  221. XS       063
  222. XT       064
  223. XU       065
  224. XV       066
  225. XW       067
  226. XX       070
  227. XY       071
  228. XZ       072
  229. X[       073
  230. X\       074
  231. X]       075
  232. X^       076
  233. X_       077
  234. X`       100
  235. Xa       101
  236. Xb       102
  237. Xc       103
  238. Xd       104
  239. Xe       105
  240. Xf       106
  241. Xg       107
  242. Xh       110
  243. Xi       111
  244. Xj       112
  245. Xk       113
  246. Xl       114
  247. Xm       115
  248. Xn       116
  249. Xo       117
  250. Xp       120
  251. Xq       121
  252. Xr       122
  253. Xs       123
  254. Xt       124
  255. Xu       125
  256. Xv       126
  257. Xw       127
  258. Xx       130
  259. Xy       131
  260. Xz       132
  261. X{       133
  262. X|       134
  263. X}       135
  264. X~       136
  265. X\|      137
  266. X\(hy    140
  267. X\(bu    141
  268. X\(sq    142
  269. X\(em    143
  270. X\(ru    144
  271. X\(14    145
  272. X\(12    146
  273. X\(34    147
  274. X\-      150
  275. X\(fi    151
  276. X\(fl    152
  277. X\(ff    153
  278. X\(Fi    154
  279. X\(Fl    155
  280. X\(de    156
  281. X\(dg    157
  282. X\(sc    160
  283. X\(fm    161
  284. X\(aa    162
  285. X\(ga    163
  286. X\(ul    164
  287. X\(sl    165
  288. X\^      166
  289. X\<sp>   167
  290. X\(*a    170
  291. X\(*b    171
  292. X\(*g    172
  293. X\(*d    173
  294. X\(*e    174
  295. X\(*z    175
  296. X\(*y    176
  297. X\(*h    177
  298. X\(*i    200
  299. X\(*k    201
  300. X\(*l    202
  301. X\(*m    203
  302. X\(*n    204
  303. X\(*c    205
  304. X\(*o    206
  305. X\(*p    207
  306. X\(*r    210
  307. X\(*s    211
  308. X\(*t    212
  309. X\(*u    213
  310. X\(*f    214
  311. X\(*x    215
  312. X\(*q    216
  313. X\(*w    217
  314. X\(*G    220
  315. X\(*D    221
  316. X\(*H    222
  317. X\(*L    223
  318. X\(*C    224
  319. X\(*P    225
  320. X\(*S    226
  321. X\(*T    227
  322. X\(*U    230
  323. X\(*F    231
  324. X\(*Q    232
  325. X\(*W    233
  326. X\(sr    234
  327. X\(ts    235
  328. X\(rn    236
  329. X\(>=    237
  330. X\(<=    240
  331. X\(==    241
  332. X\(mi    242
  333. X\(~=    243
  334. X\(ap    244
  335. X\(!=    245
  336. X\(->    246
  337. X\(<-    247
  338. X\(ua    250
  339. X\(da    251
  340. X\(eq    252
  341. X\(mu    253
  342. X\(di    254
  343. X\(+-    255
  344. X\(cu    256
  345. X\(ca    257
  346. X\(sb    260
  347. X\(sp    261
  348. X\(ib    262
  349. X\(ip    263
  350. X\(if    264
  351. X\(pd    265
  352. X\(gr    266
  353. X\(no    267
  354. X\(is    270
  355. X\(pt    271
  356. X\(es    272
  357. X\(mo    273
  358. X\(pl    274
  359. X\(rg    275
  360. X\(co    276
  361. X\(br    277
  362. X\(ct    300
  363. X\(dd    301
  364. X\(rh    302
  365. X\(lh    303
  366. X\(**    304
  367. X\(bs    305
  368. X\(or    306
  369. X\(ci    307
  370. X\(lt    310
  371. X\(lb    311
  372. X\(rt    312
  373. X\(rb    313
  374. X\(lk    314
  375. X\(rk    315
  376. X\(bv    316
  377. X\(lf    317
  378. X\(rf    320
  379. X\(lc    321
  380. X\(rc    322
  381. SHAR_EOF
  382. if test 2694 -ne "`wc -c 'charlist'`"
  383. then
  384.     echo shar: error transmitting "'charlist'" '(should have been 2694 characters)'
  385. fi
  386. echo shar: extracting "'elbat.c'" '(5459 characters)'
  387. if test -f 'elbat.c'
  388. then
  389.     echo shar: over-writing existing file "'elbat.c'"
  390. fi
  391. sed 's/^X//' << \SHAR_EOF > 'elbat.c'
  392. X/* elbat:  a program to de-compile nroff drive tables so they can
  393. X**         be fiddled with.
  394. X**
  395. X** usage:  elbat tabXXX > tabXXX.c
  396. X**
  397. X** Matt Crawford, University of Chicago, 10 May 1984
  398. X** ihnp4!oddjob!matt           crawford@anl-mcs.arpa
  399. X**
  400. X** Modified by: Bruce Townsend, Bell Northern-Research, March 6 1985
  401. X**       - Changed for USG UNIX systems.
  402. X**
  403. X*/
  404. X
  405. X#include <stdio.h>
  406. X#include <ctype.h>
  407. X#include <fcntl.h>
  408. X#include "term.h"
  409. X
  410. Xvoid    loadtab(), vprint();
  411. Xchar    *codelabel[] = {
  412. X    "space",    "!",    "\"",    "#",    "$",    "%",    "&",
  413. X    "' close",    "(",    ")",    "*",    "+",    ",",    "- hyphen",
  414. X    ".",    "/",    "0",    "1",    "2",    "3",    "4",    "5",
  415. X    "6",    "7",    "8",    "9",    ":",    ";",    "<",    "=",
  416. X    ">",    "?",    "@",    "A",    "B",    "C",    "D",    "E",
  417. X    "F",    "G",    "H",    "I",    "J",    "K",    "L",    "M",
  418. X    "N",    "O",    "P",    "Q",    "R",    "S",    "T",    "U",
  419. X    "V",    "W",    "X",    "Y",    "Z",    "[",    "\\",    "]",
  420. X    "^",    "_ dash",    "` open",    "a",    "b",    "c",
  421. X    "d",    "e",    "f",    "g",    "h",    "i",    "j",    "k",
  422. X    "l",    "m",    "n",    "o",    "p",    "q",    "r",    "s",
  423. X    "t",    "u",    "v",    "w",    "x",    "y",    "z",    "{",
  424. X    "|",    "}",    "~",    "narrow sp",    "hyphen",    "bullet",
  425. X    "square",    "3/4 em",    "rule",    "1/4",    "1/2",    "3/4",
  426. X    "minus",    "fi",    "fl",    "ff",    "ffi",    "ffl",    "degree",
  427. X    "dagger",    "section",    "foot mark",    "acute accent",
  428. X    "grave accent",    "underrule",    "slash (longer)",
  429. X    "half narrow space",    "unpaddable space",    "alpha",
  430. X    "beta",    "gamma",    "delta",    "epsilon",    "zeta",
  431. X    "eta",    "theta",    "iota",    "kappa",    "lambda",
  432. X    "mu",    "nu",    "xi",    "omicron",    "pi",    "rho",    "sigma",
  433. X    "tau",    "upsilon",    "phi",    "chi",    "psi",    "omega",
  434. X    "Gamma",    "Delta",    "Theta",    "Lambda",
  435. X    "Xi",    "Pi",    "Sigma",    "Tau",    "Upsilon",    "Phi",
  436. X    "Psi",    "Omega",    "square root",    "terminal sigma",
  437. X    "root en",    ">=",    "<=",    "identically equal",
  438. X    "equation minus",    "approx =",    "approximates",
  439. X    "not equal",    "right arrow",    "left arrow",    "up arrow",
  440. X    "down arrow",    "eqn equals",    "multiply",    "divide",
  441. X    "plus-minus",    "cup (union)",    "cap (intersection)",    "subset of",
  442. X    "superset of",    "improper subset",    " improper superset",
  443. X    "infinity",    "pt deriv",    "gradient",    "not",    "integral",
  444. X    "proportional to",    "empty set",    "member of",
  445. X    "equation plus",    "registration mk",    "copyright mk",
  446. X    "box rule",    "cent sign",    "dbl dagger",    "right hand",
  447. X    "left hand",    "math * ",    "bell system sign",
  448. X    "or (was star)",    "circle",    "left top of big curly",
  449. X    "left bottom of big curly",    "right top of big curly",
  450. X    "right bottom of big curly",    "left center of big curly",
  451. X    "right center of big curly",    "bold vertical rule",
  452. X    "left bottom of big bracket",    "right bottom of big bracket",
  453. X    "left top of big bracket",    "right top of big bracket",
  454. X    "???",    "???",    "???",    "???",    "???",    "???",    "???",    "???",
  455. X    "???",    "???",    "???",    "???",    "???",    /* No idea what these are */
  456. X};
  457. X
  458. Xstruct t t;
  459. Xstruct t_stor t_stor;
  460. X
  461. Xmain(argc, argv)
  462. Xchar    **argv;
  463. X{
  464. X    register int    c;
  465. X    register char    **endptr = &t.zzz;
  466. X    register FILE    *twfp;
  467. X    char        labelbuf[64];
  468. X
  469. X    if (argc != 2) {
  470. X        fprintf (stderr, "Usage: elbat tabXXX > tabXXX.c\n");
  471. X        exit(1);
  472. X        }
  473. X
  474. X    loadtab(argv[1]);
  475. X    if ( (twfp = fopen("term.h", "r")) == NULL ) {
  476. X        perror("term.h");
  477. X        exit(1);
  478. X    }
  479. X    
  480. X    while ( (c = getc(twfp)) != EOF && c != /*{*/ '}')
  481. X        putc(c, stdout);
  482. X    fclose(twfp);
  483. X    printf(/*{*/ "} t = {\n" /*}*/);    /* Stupid emacs! */
  484. X    printf("/*bset    */\t\t0%o,\n", t.bset);
  485. X    printf("/*breset  */\t\t0%o,\n", t.breset);
  486. X#define intshow(memb) \
  487. X        printf("/*%-8s*/\t\t%d,\n", "memb", t.memb)
  488. X    intshow(Hor);
  489. X    intshow(Vert);
  490. X    intshow(Newline);
  491. X    intshow(Char);
  492. X    intshow(Em);
  493. X    intshow(Halfline);
  494. X    intshow(Adj);
  495. X#define show(memb) \
  496. X        printf("/*%-8s*/\t\t\"", "memb");\
  497. X        vprint(t.memb);\
  498. X        printf("\",\n")
  499. X    show(twinit);
  500. X    show(twrest);
  501. X    show(twnl);
  502. X    show(hlr);
  503. X    show(hlf);
  504. X    show(flr);
  505. X    show(bdon);
  506. X    show(bdoff);
  507. X    show(iton);
  508. X    show(itoff);
  509. X    show(ploton);
  510. X    show(plotoff);
  511. X    show(up);
  512. X    show(down);
  513. X    show(right);
  514. X    show(left);
  515. X    while ( **--endptr == '\0' )
  516. X        ;
  517. X    for ( c = 0; c < 256-32        /* Not all 256-32 chars are in use */
  518. X        && &t.codetab[c] <= endptr; c++ ) {
  519. X        sprintf(labelbuf, "/* %s */", codelabel[c]);
  520. X        printf("%-20s\t\"", labelbuf);
  521. X        if ( t.codetab[c][0] )
  522. X            vprint(t.codetab[c]);
  523. X        else if ( t.codetab[c][1] ) {
  524. X            printf("\\000");
  525. X            vprint(t.codetab[c]+1);
  526. X            }
  527. X        else
  528. X            printf("\\000\\0");
  529. X        printf("\",\n");
  530. X    }
  531. X    printf(/*{*/ "};\n");
  532. X    exit(0);
  533. X}
  534. X
  535. Xvoid
  536. Xvprint(str)
  537. Xregister char    *str;
  538. X{
  539. X    while ( str && *str ) {
  540. X        char    c[5];
  541. X
  542. X        if ( isascii(*str) && isprint(*str)
  543. X                && *str != '\\' && *str != '"' ) {
  544. X            c[0] = *str;
  545. X            c[1] = '\0';
  546. X        } else
  547. X            switch ( *str ) {
  548. X            case '\\':
  549. X            case '"':
  550. X                c[0] = '\\';
  551. X                c[1] = *str;
  552. X                c[2] = '\0';
  553. X                    break;
  554. X            case '\b':
  555. X                    strcpy(c, "\\b");
  556. X                    break;
  557. X            case '\t':
  558. X                    strcpy(c, "\\t");
  559. X                    break;
  560. X            case '\n':
  561. X                    strcpy(c, "\\n");
  562. X                    break;
  563. X            case '\r':
  564. X                    strcpy(c, "\\r");
  565. X                    break;
  566. X            default:
  567. X                sprintf(c, "\\%03.3o", (int)*str & 0377);
  568. X                    break;
  569. X            }
  570. X        fputs(c, stdout);
  571. X        str++;
  572. X    }
  573. X}
  574. X
  575. Xvoid
  576. Xloadtab( tname )
  577. Xchar    *tname;
  578. X{
  579. X    register int    tfd;
  580. X    int        c_size, *ip;
  581. X    register char    **pp, *mptr;
  582. X    extern char    *malloc();
  583. X
  584. X    if( (tfd=open(tname, O_RDONLY)) < 0 ) {
  585. X        perror( tname );
  586. X        exit(1);
  587. X    }
  588. X    read(tfd, &c_size, sizeof(int));
  589. X    read(tfd, &t_stor, sizeof(t_stor));
  590. X    mptr = malloc (c_size);
  591. X    read(tfd, mptr, c_size);
  592. X    t.bset = t_stor.bset;
  593. X    t.breset = t_stor.breset;
  594. X    t.Hor = t_stor.Hor;
  595. X    t.Vert = t_stor.Vert;
  596. X    t.Newline = t_stor.Newline;
  597. X    t.Char = t_stor.Char;
  598. X    t.Em = t_stor.Em;
  599. X    t.Halfline = t_stor.Halfline;
  600. X    t.Adj = t_stor.Adj;
  601. X    ip = &t_stor.twinit;
  602. X    for ( pp = &t.twinit; pp < &t.zzz;) *pp++ = mptr + *ip++;
  603. X}
  604. SHAR_EOF
  605. if test 5459 -ne "`wc -c 'elbat.c'`"
  606. then
  607.     echo shar: error transmitting "'elbat.c'" '(should have been 5459 characters)'
  608. fi
  609. echo shar: extracting "'tabXXX.c'" '(8319 characters)'
  610. if test -f 'tabXXX.c'
  611. then
  612.     echo shar: over-writing existing file "'tabXXX.c'"
  613. fi
  614. sed 's/^X//' << \SHAR_EOF > 'tabXXX.c'
  615. X/* This is an example of a source file for an nroff driver table.
  616. X * It is a very stripped down version of a Diablo 450 in 10 pitch.
  617. X * The integer settings (bset - Adj) are correct for this terminal
  618. X * but only ascii charcters and some simple special charcters are
  619. X * included. Therefore, it is not intended as a source for a useful
  620. X * driver table, but rather as a starting point so that you can
  621. X * hack up your own.
  622. X */
  623. X
  624. X#include    <termio.h>    /* Req'd only for bset, breset */
  625. X
  626. X#define INCH 240
  627. X
  628. Xstruct {
  629. X    int bset;
  630. X    int breset;
  631. X    int Hor;
  632. X    int Vert;
  633. X    int Newline;
  634. X    int Char;
  635. X    int Em;
  636. X    int Halfline;
  637. X    int Adj;
  638. X    char *twinit;
  639. X    char *twrest;
  640. X    char *twnl;
  641. X    char *hlr;
  642. X    char *hlf;
  643. X    char *flr;
  644. X    char *bdon;
  645. X    char *bdoff;
  646. X    char *iton;
  647. X    char *itoff;
  648. X    char *ploton;
  649. X    char *plotoff;
  650. X    char *up;
  651. X    char *down;
  652. X    char *right;
  653. X    char *left;
  654. X    char *codetab[256-32];
  655. X    char *zzz;
  656. X    } t = {
  657. X/*bset    */        0,
  658. X/*breset  */        ONLCR | OCRNL | ONLRET,
  659. X/*Hor     */        INCH / 60,
  660. X/*Vert    */        INCH / 48,
  661. X/*Newline */        INCH / 6,
  662. X/*Char    */        INCH / 10,
  663. X/*Em      */        INCH / 10,
  664. X/*Halfline*/        INCH / 12,
  665. X/*Adj     */        INCH / 10,
  666. X/*twinit  */        "",
  667. X/*twrest  */        "",
  668. X/*twnl    */        "",
  669. X/*hlr     */        "",
  670. X/*hlf     */        "",
  671. X/*flr     */        "",
  672. X/*bdon    */        "",
  673. X/*bdoff   */        "",
  674. X/*iton    */        "",
  675. X/*itoff   */        "",
  676. X/*ploton  */        "",
  677. X/*plotoff */        "",
  678. X/*up      */        "",
  679. X/*down    */        "",
  680. X/*right   */        "",
  681. X/*left    */        "",
  682. X/* space */             "\001 ",
  683. X/* ! */                 "\001!",
  684. X/* " */                 "\001\"",
  685. X/* # */                 "\001#",
  686. X/* $ */                 "\001$",
  687. X/* % */                 "\001%",
  688. X/* & */                 "\001&",
  689. X/* ' close */           "\001'",
  690. X/* ( */                 "\001(",
  691. X/* ) */                 "\001)",
  692. X/* * */                 "\001*",
  693. X/* + */                 "\001+",
  694. X/* , */                 "\001,",
  695. X/* - hyphen */          "\001-",
  696. X/* . */                 "\001.",
  697. X/* / */                 "\001/",
  698. X/* 0 */                 "\2010",
  699. X/* 1 */                 "\2011",
  700. X/* 2 */                 "\2012",
  701. X/* 3 */                 "\2013",
  702. X/* 4 */                 "\2014",
  703. X/* 5 */                 "\2015",
  704. X/* 6 */                 "\2016",
  705. X/* 7 */                 "\2017",
  706. X/* 8 */                 "\2018",
  707. X/* 9 */                 "\2019",
  708. X/* : */                 "\001:",
  709. X/* ; */                 "\001;",
  710. X/* < */                 "\001<",
  711. X/* = */                 "\001=",
  712. X/* > */                 "\001>",
  713. X/* ? */                 "\001?",
  714. X/* @ */                 "\001@",
  715. X/* A */                 "\201A",
  716. X/* B */                 "\201B",
  717. X/* C */                 "\201C",
  718. X/* D */                 "\201D",
  719. X/* E */                 "\201E",
  720. X/* F */                 "\201F",
  721. X/* G */                 "\201G",
  722. X/* H */                 "\201H",
  723. X/* I */                 "\201I",
  724. X/* J */                 "\201J",
  725. X/* K */                 "\201K",
  726. X/* L */                 "\201L",
  727. X/* M */                 "\201M",
  728. X/* N */                 "\201N",
  729. X/* O */                 "\201O",
  730. X/* P */                 "\201P",
  731. X/* Q */                 "\201Q",
  732. X/* R */                 "\201R",
  733. X/* S */                 "\201S",
  734. X/* T */                 "\201T",
  735. X/* U */                 "\201U",
  736. X/* V */                 "\201V",
  737. X/* W */                 "\201W",
  738. X/* X */                 "\201X",
  739. X/* Y */                 "\201Y",
  740. X/* Z */                 "\201Z",
  741. X/* [ */                 "\001[",
  742. X/* \ */                 "\001\\",
  743. X/* ] */                 "\001]",
  744. X/* ^ */                 "\001^",
  745. X/* _ dash */            "\001_",
  746. X/* ` open */            "\001`",
  747. X/* a */                 "\201a",
  748. X/* b */                 "\201b",
  749. X/* c */                 "\201c",
  750. X/* d */                 "\201d",
  751. X/* e */                 "\201e",
  752. X/* f */                 "\201f",
  753. X/* g */                 "\201g",
  754. X/* h */                 "\201h",
  755. X/* i */                 "\201i",
  756. X/* j */                 "\201j",
  757. X/* k */                 "\201k",
  758. X/* l */                 "\201l",
  759. X/* m */                 "\201m",
  760. X/* n */                 "\201n",
  761. X/* o */                 "\201o",
  762. X/* p */                 "\201p",
  763. X/* q */                 "\201q",
  764. X/* r */                 "\201r",
  765. X/* s */                 "\201s",
  766. X/* t */                 "\201t",
  767. X/* u */                 "\201u",
  768. X/* v */                 "\201v",
  769. X/* w */                 "\201w",
  770. X/* x */                 "\201x",
  771. X/* y */                 "\201y",
  772. X/* z */                 "\201z",
  773. X/* { */                 "\001{",
  774. X/* | */                 "\001|",
  775. X/* } */                 "\001}",
  776. X/* ~ */                 "\001~",
  777. X/* narrow sp */         "\000\0",
  778. X/* hyphen */            "\001-",
  779. X/* bullet */            "\000\0",
  780. X/* square */            "\000\0",
  781. X/* 3/4 em */            "\001-",
  782. X/* rule */              "\001_",
  783. X/* 1/4 */               "\0031/4",
  784. X/* 1/2 */               "\0031/2",
  785. X/* 3/4 */               "\0033/4",
  786. X/* minus */             "\001-",
  787. X/* fi */                "\202fi",
  788. X/* fl */                "\202fl",
  789. X/* ff */                "\202ff",
  790. X/* ffi */               "\203ffi",
  791. X/* ffl */               "\203ffl",
  792. X/* degree */            "\000\0",
  793. X/* dagger */            "\000\0",
  794. X/* section */           "\000\0",
  795. X/* foot mark */         "\000\0",
  796. X/* acute accent */      "\000\0",
  797. X/* grave accent */      "\000\0",
  798. X/* underrule */         "\001_",
  799. X/* slash (longer) */    "\001/",
  800. X/* half narrow space */    "\000\0",
  801. X/* unpaddable space */    "\001 ",
  802. X/* alpha */             "\000\0",
  803. X/* beta */              "\000\0",
  804. X/* gamma */             "\000\0",
  805. X/* epsilon */           "\000\0",
  806. X/* zeta */              "\000\0",
  807. X/* eta */               "\000\0",
  808. X/* theta */             "\000\0",
  809. X/* iota */              "\000\0",
  810. X/* kappa */             "\000\0",
  811. X/* lambda */            "\000\0",
  812. X/* mu */                "\000\0",
  813. X/* nu */                "\000\0",
  814. X/* xi */                "\000\0",
  815. X/* omicron */           "\000\0",
  816. X/* pi */                "\000\0",
  817. X/* rho */               "\000\0",
  818. X/* sigma */             "\000\0",
  819. X/* tau */               "\000\0",
  820. X/* upsilon */           "\000\0",
  821. X/* phi */               "\000\0",
  822. X/* chi */               "\000\0",
  823. X/* psi */               "\000\0",
  824. X/* omega */             "\000\0",
  825. X/* Gamma */             "\000\0",
  826. X/* Delta */             "\000\0",
  827. X/* Theta */             "\000\0",
  828. X/* Lambda */            "\000\0",
  829. X/* Xi */                "\000\0",
  830. X/* Pi */                "\000\0",
  831. X/* Sigma */             "\000\0",
  832. X/* Tau */               "\000\0",
  833. X/* Upsilon */           "\000\0",
  834. X/* Phi */               "\000\0",
  835. X/* Psi */               "\000\0",
  836. X/* Omega */             "\000\0",
  837. X/* square root */       "\000\0",
  838. X/* terminal sigma */    "\000\0",
  839. X/* root en */           "\000\0",
  840. X/* >= */                "\000\0",
  841. X/* <= */                "\000\0",
  842. X/* identically equal */    "\000\0",
  843. X/* equation minus */    "\000\0",
  844. X/* approx = */          "\000\0",
  845. X/* approximates */      "\000\0",
  846. X/* not equal */         "\000\0",
  847. X/* right arrow */       "\000\0",
  848. X/* left arrow */        "\000\0",
  849. X/* up arrow */          "\000\0",
  850. X/* down arrow */        "\000\0",
  851. X/* eqn equals */        "\000\0",
  852. X/* multiply */          "\000\0",
  853. X/* divide */            "\000\0",
  854. X/* plus-minus */        "\000\0",
  855. X/* cup (union) */       "\000\0",
  856. X/* cap (intersection) */    "\000\0",
  857. X/* subset of */         "\000\0",
  858. X/* superset of */       "\000\0",
  859. X/* improper subset */    "\000\0",
  860. X/*  improper superset */    "\000\0",
  861. X/* infinity */          "\000\0",
  862. X/* pt deriv */          "\000\0",
  863. X/* gradient */          "\000\0",
  864. X/* not */               "\000\0",
  865. X/* integral */          "\000\0",
  866. X/* proportional to */    "\000\0",
  867. X/* empty set */         "\000\0",
  868. X/* member of */         "\000\0",
  869. X/* equation plus */     "\001+",
  870. X/* registration mk */    "\000\0",
  871. X/* copyright mk */      "\000\0",
  872. X/* box rule */          "\001|",
  873. X/* cent sign */         "\000\0",
  874. X/* dbl dagger */        "\000\0",
  875. X/* right hand */        "\000\0",
  876. X/* left hand */         "\000\0",
  877. X/* math *  */           "\001*",
  878. X/* bell system sign */    "\000\0",
  879. X/* or (was star) */     "\001|",
  880. X/* circle */            "\000\0",
  881. X/* left top of big curly */    "\001|",
  882. X/* left bottom of big curly */    "\001|",
  883. X/* right top of big curly */    "\001|",
  884. X/* right bottom of big curly */    "\001|",
  885. X/* left center of big curly */    "\001|",
  886. X/* right center of big curly */    "\001|",
  887. X/* bold vertical rule */    "\001|",
  888. X/* left bottom of big bracket */    "\001|",
  889. X/* right bottom of big bracket */    "\001|",
  890. X/* left top of big bracket */    "\001|",
  891. X/* right top of big bracket */    "\001|",
  892. X/* ??? */               "\000\0",
  893. X/* ??? */               "\000\0",
  894. X/* ??? */               "\000\0",
  895. X/* ??? */               "\000\0",
  896. X/* ??? */               "\000\0",
  897. X/* ??? */               "\000\0",
  898. X/* ??? */               "\000\0",
  899. X/* ??? */               "\000\0",
  900. X/* ??? */               "\000\0",
  901. X/* ??? */               "\000\0",
  902. X/* ??? */               "\000\0",
  903. X/* ??? */               "\000\0",
  904. X/* ??? */               "\000\0",
  905. X};
  906. SHAR_EOF
  907. if test 8319 -ne "`wc -c 'tabXXX.c'`"
  908. then
  909.     echo shar: error transmitting "'tabXXX.c'" '(should have been 8319 characters)'
  910. fi
  911. echo shar: extracting "'table.c'" '(7221 characters)'
  912. if test -f 'table.c'
  913. then
  914.     echo shar: over-writing existing file "'table.c'"
  915. fi
  916. sed 's/^X//' << \SHAR_EOF > 'table.c'
  917. X/*
  918. X *
  919. X *     TABLE - A PROGRAM TO PREPARE NROFF DRIVER TABLES
  920. X *     copyright (c) 1985 by Bruce Townsend and Bell-Northern Research.
  921. X *     Permission hereby granted to use, distribute, modify, or copy
  922. X *     except for profit, providing this disclaimer is included.
  923. X *
  924. X *     The contributions of Ian Darwin (the Makefile, cleaning up the
  925. X *     code, etc) are gratefully acknowledged.
  926. X *
  927. X *     Version 1.2 -
  928. X *        * The program has been substantially modified from version 1.1
  929. X *          The major bug in version 1.1 was that zero-width characters
  930. X *          were not handled properly. This has been fixed.
  931. X *
  932. X *     Please send bug reports to Bruce Townsend (utcs!bnr-vpa!bruce)
  933. X *
  934. X *     Usage:
  935. X *           1) Build a file tabXXX.c, where XXX is some reasonable
  936. X *              acronym for the terminal or printer you want to drive
  937. X *              (peruse existing names to see what's reasonable!).
  938. X *              Make this file by hacking up one of the existing
  939. X *              table entries.
  940. X *           2) If the amount of char data that the structure
  941. X *              references is very large, you may want to redefine
  942. X *              C_SIZE
  943. X *           3) check to see whether <sgtty.h> or <termio.h> should
  944. X *              be #included in the tabXXX.c file. One of these include
  945. X *              files may be necessary to provide settings for t.bset,
  946. X *              t.breset. This is instead of the previous tendency to code
  947. X *              octal magic numbers in these fields.
  948. X *           4) Enter your new table into the Makefile; just add the
  949. X *              name "tabXXX" to the TABFILES definition.
  950. X *           5) Type "make tabXXX" where tabXXX is the same name
  951. X *              you chose before.
  952. X *           6) Locate the tabfile in the proper place (on our system
  953. X *              the directory is /usr/lib/term
  954. X *
  955. X *
  956. X */
  957. X
  958. X#define C_SIZE    10000    /* The maximum amount of character data allowed
  959. X               in the initialized structure t - increase if
  960. X               necessary */
  961. X
  962. X#include <stdio.h>
  963. X#include "term.h"    /* This file contains the definition of the
  964. X               the structures t and t_stor */
  965. X
  966. X/************* DO NOT ALTER ANYTHING AFTER THIS POINT ***************/
  967. X
  968. Xextern struct t t;
  969. Xstruct t_stor t_stor;
  970. X
  971. Xchar    c_data[C_SIZE];
  972. Xchar    *c_pointer[256];
  973. Xint    c_length[256];
  974. Xchar    *c_end = c_data;
  975. Xint    n_strings, c_size;
  976. X
  977. Xmain (argc, argv)
  978. Xint    argc;
  979. Xchar    *argv[];
  980. X{
  981. X    FILE    *table;
  982. X    int    i, j, i_len, j_len;
  983. X    char    *tail, *start, *char_pointer, *strcpy();
  984. X
  985. X    if (argc != 2) {    /* Need a file name argument */
  986. X        fprintf (stderr, "Usage: table \"file\"\n");
  987. X        exit (1);
  988. X        }
  989. X
  990. X    /* Open the file */
  991. X    if ((table = fopen (argv[1], "w")) == NULL) {
  992. X        fprintf (stderr, "File %s not opened for writing\n", argv[1]);
  993. X        exit (1);
  994. X        }
  995. X
  996. X    /* Copy the integer values from the initialized structure
  997. X       to the storage structure */
  998. X    t_stor.bset = t.bset;
  999. X    t_stor.breset = t.breset;
  1000. X    t_stor.Hor = t.Hor;
  1001. X    t_stor.Vert = t.Vert;
  1002. X    t_stor.Newline = t.Newline;
  1003. X    t_stor.Char = t.Char;
  1004. X    t_stor.Em = t.Em;
  1005. X    t_stor.Halfline = t.Halfline;
  1006. X    t_stor.Adj = t.Adj;
  1007. X
  1008. X    /* Add the character strings into a character array */
  1009. X    addstring (t.twinit);
  1010. X    addstring (t.twrest);
  1011. X    addstring (t.twnl);
  1012. X    addstring (t.hlr);
  1013. X    addstring (t.hlf);
  1014. X    addstring (t.flr);
  1015. X    addstring (t.bdon);
  1016. X    addstring (t.bdoff);
  1017. X    addstring (t.iton);
  1018. X    addstring (t.itoff);
  1019. X    addstring (t.ploton);
  1020. X    addstring (t.plotoff);
  1021. X    addstring (t.up);
  1022. X    addstring (t.down);
  1023. X    addstring (t.right);
  1024. X    addstring (t.left);
  1025. X    for (i = 0; i < 256 - 32; i++) addchar (t.codetab[i]);
  1026. X
  1027. X    /* eliminate strings which are tails of other strings */
  1028. X    for (i = 0; i < n_strings; i++) {
  1029. X        if (! c_pointer[i]) continue;    /* String cleared out */
  1030. X        i_len = c_length[i];
  1031. X        for (j = 0; j < n_strings; j++) {
  1032. X        if (i == j || ! c_pointer[j]) continue;
  1033. X        j_len = c_length[j];
  1034. X        if (i_len <= j_len) {    /* string i could be tail of string j */
  1035. X            tail = c_pointer[j] + j_len - i_len;
  1036. X            if (! char_comp (c_pointer[i], tail, i_len)) {
  1037. X            c_pointer[i] = 0;
  1038. X            break;
  1039. X            }
  1040. X            }
  1041. X        }
  1042. X        }
  1043. X
  1044. X    /* Compress the c_data array */
  1045. X    char_pointer = c_data;
  1046. X    for (i = j = 0; i < n_strings; i++) {
  1047. X        if (! (start = c_pointer[i])) continue;
  1048. X        c_pointer[j] = char_pointer;
  1049. X        c_length[j++] = c_length[i];
  1050. X        for (i_len = c_length[i]; i_len--;) *char_pointer++ = *start++;
  1051. X        *char_pointer++ = 0;
  1052. X        }
  1053. X    n_strings = j;
  1054. X    c_size = char_pointer - c_data;
  1055. X
  1056. X    /* Now find each string in this table and provide an index to it */
  1057. X    t_stor.twinit = findstring (t.twinit);
  1058. X    t_stor.twrest = findstring (t.twrest);
  1059. X    t_stor.twnl = findstring (t.twnl);
  1060. X    t_stor.hlr = findstring (t.hlr);
  1061. X    t_stor.hlf = findstring (t.hlf);
  1062. X    t_stor.flr = findstring (t.flr);
  1063. X    t_stor.bdon = findstring (t.bdon);
  1064. X    t_stor.bdoff = findstring (t.bdoff);
  1065. X    t_stor.iton = findstring (t.iton);
  1066. X    t_stor.itoff = findstring (t.itoff);
  1067. X    t_stor.ploton = findstring (t.ploton);
  1068. X    t_stor.plotoff = findstring (t.plotoff);
  1069. X    t_stor.up = findstring (t.up);
  1070. X    t_stor.down = findstring (t.down);
  1071. X    t_stor.right = findstring (t.right);
  1072. X    t_stor.left = findstring (t.left);
  1073. X    for (i = 0; i < 256 - 32; i++) {
  1074. X        t_stor.codetab[i] = findchar (t.codetab[i]);
  1075. X        }
  1076. X    t_stor.zzz = 0;
  1077. X
  1078. X    /* Write the character storage block size */
  1079. X    if (fwrite (&c_size, sizeof (c_size), 1, table) != 1)
  1080. X        write_err ();
  1081. X
  1082. X    if (fwrite (&t_stor, sizeof (t_stor), 1, table) != 1)
  1083. X        write_err ();
  1084. X
  1085. X    if (fwrite (c_data, sizeof (*c_data), c_size, table) != c_size)
  1086. X        write_err ();
  1087. X
  1088. X    if (fclose (table)) {
  1089. X        fprintf (stderr, "File %s not closed properly\n", argv[1]);
  1090. X        exit (1);
  1091. X        }
  1092. X    }
  1093. X
  1094. Xaddstring (string)
  1095. Xchar    *string;
  1096. X{
  1097. X    c_pointer[n_strings] = c_end;
  1098. X    c_end += (c_length[n_strings] = strlen (string)) + 1;
  1099. X    if (c_end >= c_data + C_SIZE) {
  1100. X        fprintf (stderr, "Table size too small, increase it!\n");
  1101. X        exit(1);
  1102. X        }
  1103. X    strcpy (c_pointer[n_strings++], string);
  1104. X}
  1105. X
  1106. Xaddchar (string)
  1107. Xchar    *string;
  1108. X{
  1109. X    c_pointer[n_strings] = c_end;
  1110. X    c_end += (c_length[n_strings] = strlen (string + 2) + 2) + 1;
  1111. X    if (c_end >= c_data + C_SIZE) {
  1112. X        fprintf (stderr, "Table size too small, increase it!\n");
  1113. X        exit(1);
  1114. X        }
  1115. X    *c_pointer[n_strings] = *string++;    /* Copy in first two bytes */
  1116. X    *(c_pointer[n_strings]+1) = *string++;
  1117. X    strcpy (c_pointer[n_strings++] + 2, string); /* Copy the rest */
  1118. X}
  1119. X
  1120. Xchar_comp (str1, str2, len)
  1121. Xchar    *str1, *str2;
  1122. Xint    len;
  1123. X{
  1124. X    while (len--) {
  1125. X        if (*str1++ != *str2++) return (1);
  1126. X        }
  1127. X    return (0);
  1128. X    }
  1129. X
  1130. Xfindstring (string)
  1131. Xchar    *string;
  1132. X{
  1133. X    int    c_len, s_len, i;
  1134. X
  1135. X    for (i = 0; i < n_strings; i++) {
  1136. X        if ((c_len = c_length[i]) >= (s_len = strlen (string))) {
  1137. X        if (!char_comp (string, c_pointer[i] + c_len - s_len, s_len))
  1138. X            return (c_pointer[i] + c_len - s_len - c_data);
  1139. X        }
  1140. X        }
  1141. X    fprintf (stderr, "Serious bug! string not found in table\n");
  1142. X    exit(1);
  1143. X    /* NOTREACHED */
  1144. X    }
  1145. X
  1146. Xfindchar (string)
  1147. Xchar    *string;
  1148. X{
  1149. X    int    c_len, s_len, i;
  1150. X
  1151. X    for (i = 0; i < n_strings; i++) {
  1152. X        if ((c_len = c_length[i]) >= (s_len = strlen (string+2) + 2)) {
  1153. X        if (!char_comp (string, c_pointer[i] + c_len - s_len, s_len))
  1154. X            return (c_pointer[i] + c_len - s_len - c_data);
  1155. X        }
  1156. X        }
  1157. X    fprintf (stderr, "Serious bug! character not found in table\n");
  1158. X    exit(1);
  1159. X    /* NOTREACHED */
  1160. X    }
  1161. X
  1162. Xwrite_err () {
  1163. X    fprintf (stderr, "Write to file failed\n");
  1164. X    exit (1);
  1165. X    }
  1166. SHAR_EOF
  1167. if test 7221 -ne "`wc -c 'table.c'`"
  1168. then
  1169.     echo shar: error transmitting "'table.c'" '(should have been 7221 characters)'
  1170. fi
  1171. echo shar: extracting "'table.doc'" '(6854 characters)'
  1172. if test -f 'table.doc'
  1173. then
  1174.     echo shar: over-writing existing file "'table.doc'"
  1175. fi
  1176. sed 's/^X//' << \SHAR_EOF > 'table.doc'
  1177. XDOCUMENTATION OF NROFF TAB FILE UTILITY
  1178. X-Bruce Townsend, Bell-Northern Research, March 1985
  1179. X (utcs!bnr-vpa!bruce)
  1180. X
  1181. X    This file contains some documentation for the table program.
  1182. XThis program makes printer and terminal driver tables suitable for
  1183. Xnroff. The development of this program was motivated by the lack of
  1184. Xany other means to prepare custom nroff driver tables, for those
  1185. Xsystems which do not have the original source that prepared the driver
  1186. Xtables (usually found in /usr/lib/term).
  1187. X    The format for the tables imbodied in this program was deduced
  1188. Xfrom a "term" manual page, and by examining the contents of several
  1189. Xexisting tab files. Therefore, this program is not definitive in
  1190. Xany sense, but is intended as a help for those who (like myself) do
  1191. Xnot have access to any formal tools that make these tab files.
  1192. X    Also it is possible that this program will require modification
  1193. Xfor systems where the size of an integer is not 32 bits. The system
  1194. Xthat this program was developed on is an HP9000 (System III) and the
  1195. Xdata sizes are:
  1196. X        long    32
  1197. X        int    32
  1198. X        short    16
  1199. X        char     8
  1200. XAs I have not had access to different machines, I do not know whether
  1201. Xcertain data in the tab file is of int or long type, since that type
  1202. Xis the same on our machine. I have assumed int type.
  1203. X
  1204. XIf your luck is really bad, I suppose it is possible that the format
  1205. Xof the tab file is different across various implementations.
  1206. X
  1207. XThe format of the tab file is:
  1208. XType    Name        Size on HP9000        Description
  1209. X----    ----        --------------        -----------
  1210. Xint    c_size        4 bytes    - The amount of character data in bytes
  1211. X                that follows the t_stor structure. In fact
  1212. X                the size of the file in bytes should be:
  1213. X                c_size + sizeof (c_size) + sizeof (t_stor)
  1214. X                (On our machine: c_size + 1004)
  1215. X
  1216. Xstruct {        1000 bytes - This is the storage for the "t"
  1217. X    int bset;        structure with one change. All the elements
  1218. X    int breset;        of the t structure which were pointers to
  1219. X    int Hor;        strings are now integer indexes to one
  1220. X    int Vert;        large character array.
  1221. X    int Newline;
  1222. X    int Char;
  1223. X    int Em;
  1224. X    int Halfline;
  1225. X    int Adj;
  1226. X    int twinit;
  1227. X    int twrest;
  1228. X    int twnl;
  1229. X    int hlr;
  1230. X    int hlf;
  1231. X    int flr;
  1232. X    int bdon;
  1233. X    int bdoff;
  1234. X    int iton;
  1235. X    int itoff;
  1236. X    int ploton;
  1237. X    int plotoff;
  1238. X    int up;
  1239. X    int down;
  1240. X    int right;
  1241. X    int left;
  1242. X    int codetab[256-32];
  1243. X    int zzz;
  1244. X} t_stor;
  1245. X
  1246. Xchar    array[c_size]    (variable size)- This is the storage for the strings
  1247. X                    pointed to by the indexes.
  1248. X
  1249. X        How to Use the Table Program
  1250. X        ----------------------------
  1251. XExamine the "term" manual page which explains the purpose of each of
  1252. Xthe items in the "t" structure. Make a copy of the tabXXX.c program
  1253. Xand edit it, replacing XXX with a suitable mnemonic. Initialize the
  1254. Xt structure to the integer or character string values that are necessary
  1255. Xfor the terminal or printer in question. You have a high degree of
  1256. Xflexibility here, and variable-width characters, overstrike combinations,
  1257. Xetc are easy to implement.
  1258. X
  1259. XThe only catch here is determining which index of the t.codetab[] array
  1260. Xcorresponds to which nroff printable character. This information is not
  1261. Xin the manual page. After some experimentation, I have made a table
  1262. Xwhich list the characters I know about. The table has some holes in it,
  1263. Xbut is as complete as I can make it. If anyone has additions or
  1264. Xcorrections, please let me know. The table is found in the file
  1265. Xcharlist. Also, the comments in tabXXX.c should help.
  1266. X
  1267. XWARNING: ALL CHARACTER STRINGS IN THE codetab[] array MUST be at
  1268. Xleast two characters in size, not counting the null terminator.
  1269. XThe typical definition for a zero-width string which prints nothing
  1270. Xis "\000\0" and NOT "". THIS IS VERY IMPORTANT, because it is
  1271. Xnecessary to allow the first byte of these strings to be zero
  1272. Xin the case of zero-width strings that do print something.
  1273. XE.G. the string "\000^\b" is a zero-width "hat" character.
  1274. X
  1275. XIf the amount of char data is very large, you may need to increase the
  1276. Xdefinition of C_SIZE in table.c. It is now set at 10000 characters.
  1277. XThe table.c program will burp out a message to this effect if
  1278. Xnecessary.
  1279. X
  1280. XThe t.bset and t.breset flags will need definitions from either
  1281. X<termio.h> or <sgtty.h>. Include whichever is appropriate for your
  1282. Xsystem in tabXXX.c.
  1283. X
  1284. XAfter the tabXXX.c file has been edited, place it in the same
  1285. Xdirectory as table.c and the Makefile, and compile the table with:
  1286. X    make tabXXX
  1287. X
  1288. XThis will compile and run a program which will in turn make the
  1289. Xtab file. Move the tabfile to its destination directory (likely
  1290. X/usr/term/tab).
  1291. X
  1292. XRun nroff as:
  1293. X    nroff -TXXX ...
  1294. X(for example):
  1295. X    nroff -T630P ...
  1296. X
  1297. XDebugging is not easy.
  1298. XYou can use the supplied program which takes a tab file (tabXXX) and
  1299. Xmakes a source file (tabXXX.c). The program is called elbat (reverse
  1300. Xof table) Do this by:
  1301. X    elbat tabXXX > tabXXX.c
  1302. Xand compare to your original tabXXX.c
  1303. X    Do this for tab files that you have already to check that
  1304. Xthe format is the same on your system as on mine.
  1305. X
  1306. X
  1307. X        The Table Program
  1308. X        -----------------
  1309. X
  1310. XAs mentioned before, this program is not to be considered a
  1311. Xdefinitive one. It works for HP9000's as far as I can tell.
  1312. X
  1313. XHowever, it does have the feature of compressing the supplied
  1314. Xcharacter data as much as possible. If one string is the tail of
  1315. Xanother (e.g. the strings abcdef and def), than only the largest
  1316. Xstring is stored. The smaller is indexed into the middle of the
  1317. Xlarger. Repeated strings (including the null string) are only stored
  1318. Xonce.
  1319. X
  1320. XIt should generate a tabfile very close to the size of the distributed
  1321. Xtables. Check by using elbat on a distributed table, compile using
  1322. Xthe table utility, and compare the sizes. The character data will
  1323. Xalmost certainly be stored in a different order than in the
  1324. Xdistributed table, so "cmp -l" will find most bytes different.
  1325. XHowever, the nroff results using the two files should be identical.
  1326. X
  1327. XThe program has not been extensively tested. There may be bugs or
  1328. Xmisinformation. Let me know of any problems.
  1329. X
  1330. XIf the tab files produced by this program do not work at all on your
  1331. Xsystem, then it may be that the data types for c_size, and
  1332. Xt_stor.whatever are incorrect. (Long instead of int?) You can get an
  1333. Xindication by looking at the first word (int or long?) of an
  1334. Xexisting tab file. This is the amount of char data stored in the
  1335. Xfile. Subtract it from the size of the file in bytes. The result
  1336. Xwill be the size of the t_stor structure plus the size of the c_size
  1337. Xvariable. The t_stor structure has 250 elements in it. If each is
  1338. X4 bytes, as on our system, and the c_size variable is 4 bytes also,
  1339. Xthen the result of the previous subtraction should be 1004. If
  1340. Xthe sizeof(int) on your system is 16 bits, then the difference
  1341. Xshould be 502. If it is not, then perhaps the types (some or all)
  1342. Xof c_size, and the elements in t_stor should be changed to reflect
  1343. Xthis.
  1344. X
  1345. X            Good luck!
  1346. X
  1347. XI can be reached at:
  1348. X
  1349. X        utcs!bnr-vpa!bruce            (UUCP)
  1350. Xor        (613) 726 - 3008            (Phone)
  1351. X        (Ottawa, Canada)
  1352. X
  1353. SHAR_EOF
  1354. if test 6854 -ne "`wc -c 'table.doc'`"
  1355. then
  1356.     echo shar: error transmitting "'table.doc'" '(should have been 6854 characters)'
  1357. fi
  1358. echo shar: extracting "'term.5'" '(6192 characters)'
  1359. if test -f 'term.5'
  1360. then
  1361.     echo shar: over-writing existing file "'term.5'"
  1362. fi
  1363. sed 's/^X//' << \SHAR_EOF > 'term.5'
  1364. X.TH TERM 5
  1365. X.SH NAME
  1366. Xterm \- terminal driving tables for nroff
  1367. X.SH DESCRIPTION
  1368. X.IR Nroff (1)
  1369. Xuses driving tables to customize its output for various types of
  1370. Xoutput devices, such as printing terminals, special word-processing
  1371. Xterminals (such as Diablo, Qume, or NEC Spinwriter mechanisms),
  1372. Xor special output filter programs.  These driving tables are written
  1373. Xas C programs, compiled, and installed in
  1374. X\f3/usr/lib/term/tab\f2name\fP ,
  1375. Xwhere
  1376. X.I name\^
  1377. Xis the name for that terminal type as given in
  1378. X.IR term (7).
  1379. XThe structure of the tables is as follows:
  1380. X.PP
  1381. X.nf
  1382. X.ta 5m 10m 15m 20m 25m 30m 35m 40m 45m 50m 55m 60m
  1383. X#define    INCH    240
  1384. X
  1385. Xstruct {
  1386. X    int bset;
  1387. X    int breset;
  1388. X    int Hor;
  1389. X    int Vert;
  1390. X    int Newline;
  1391. X    int Char;
  1392. X    int Em;
  1393. X    int Halfline;
  1394. X    int Adj;
  1395. X    char *twinit;
  1396. X    char *twrest;
  1397. X    char *twnl;
  1398. X    char *hlr;
  1399. X    char *hlf;
  1400. X    char *flr;
  1401. X    char *bdon;
  1402. X    char *bdoff;
  1403. X    char *iton;
  1404. X    char *itoff;
  1405. X    char *ploton;
  1406. X    char *plotoff;
  1407. X    char *up;
  1408. X    char *down;
  1409. X    char *right;
  1410. X    char *left;
  1411. X    char *codetab[256\-32];
  1412. X    char *zzz;
  1413. X} t;
  1414. X.fi
  1415. X.DT
  1416. X.PP
  1417. XThe meanings of the various fields are as follows:
  1418. X.TP 10
  1419. X.I bset\^
  1420. Xbits to set in the
  1421. X.I c_oflag\^
  1422. Xfield of the
  1423. X.I termio\^
  1424. Xstructure (see
  1425. X.IR tty (4))
  1426. Xbefore output.
  1427. X.TP 10
  1428. X.I breset\^
  1429. Xbits to reset in the
  1430. X.I c_oflag\^
  1431. Xfield of the
  1432. X.I termio\^
  1433. Xstructure
  1434. Xbefore output.
  1435. X.TP 10
  1436. X.I Hor\^
  1437. Xhorizontal resolution in fractions of an inch.
  1438. X.TP 10
  1439. X.I Vert\^
  1440. Xvertical resolution in fractions of an inch.
  1441. X.TP 10
  1442. X.I Newline\^
  1443. Xspace moved by a newline (linefeed) character in fractions
  1444. Xof an inch.
  1445. X.TP 10
  1446. X.I Char\^
  1447. Xquantum of character sizes, in fractions of an inch.
  1448. X(i.e., a character is a multiple of Char units wide)
  1449. X.TP 10
  1450. X.I Em\^
  1451. Xsize of an em in fractions of an inch.
  1452. X.TP 10
  1453. X.I Halfline\^
  1454. Xspace moved by a half-linefeed (or half-reverse-linefeed)
  1455. Xcharacter in fractions of an inch.
  1456. X.TP 10
  1457. X.I Adj\^
  1458. Xquantum of white space, in fractions of an inch.
  1459. X(i.e., white spaces are a multiple of Adj units wide)
  1460. X.IP
  1461. XNote: if this is less than the size of the space
  1462. Xcharacter (in units of Char; see below for how the
  1463. Xsizes of characters are defined),
  1464. X.I nroff\^
  1465. Xwill output
  1466. Xfractional spaces using plot mode.  Also, if the
  1467. X.B \-e
  1468. Xswitch to
  1469. X.I nroff\^
  1470. Xis used, Adj is set equal to Hor by
  1471. X.IR nroff .
  1472. X.TP 10
  1473. X.I twinit\^
  1474. Xset of characters used to initialize the terminal
  1475. Xin a mode suitable for
  1476. X.IR nroff .
  1477. X.TP 10
  1478. X.I twrest\^
  1479. Xset of characters used to restore the terminal to
  1480. Xnormal mode.
  1481. X.TP 10
  1482. X.I twnl\^
  1483. Xset of characters used to move down one line.
  1484. X.TP 10
  1485. X.I hlr\^
  1486. Xset of characters used to move up one-half line.
  1487. X.TP 10
  1488. X.I hlf\^
  1489. Xset of characters used to move down one-half line.
  1490. X.TP 10
  1491. X.I flr\^
  1492. Xset of characters used to move up one line.
  1493. X.TP 10
  1494. X.I bdon\^
  1495. Xset of characters used to turn on hardware boldface mode,
  1496. Xif any.
  1497. X.I Nroff\^
  1498. Xassumes that boldface mode is reset automatically by the
  1499. X.I twnl\^
  1500. Xstring, because many letter-quality printers reset the boldface
  1501. Xmode when they receive a carriage return;
  1502. Xthe
  1503. X.I twnl\^
  1504. Xstring should include whatever characters are necessary to
  1505. Xreset the boldface mode.
  1506. X.TP 10
  1507. X.I bdoff\^
  1508. Xset of characters used to turn off hardware boldface mode,
  1509. Xif any.
  1510. X.TP 10
  1511. X.I iton\^
  1512. Xset of characters used to turn on hardware italics mode,
  1513. Xif any.
  1514. X.TP 10
  1515. X.I itoff\^
  1516. Xset of characters used to turn off hardware italics mode,
  1517. Xif any.
  1518. X.TP 10
  1519. X.I ploton\^
  1520. Xset of characters used to turn on hardware plot mode
  1521. X(for Diablo type mechanisms), if any.
  1522. X.TP 10
  1523. X.I plotoff\^
  1524. Xset of characters used to turn off hardware plot mode
  1525. X(for Diablo type mechanisms), if any.
  1526. X.TP 10
  1527. X.I up\^
  1528. Xset of characters used to move up one resolution unit
  1529. X(Vert) in plot mode, if any.
  1530. X.TP 10
  1531. X.I down\^
  1532. Xset of characters used to move down one resolution unit
  1533. X(Vert) in plot mode, if any.
  1534. X.TP 10
  1535. X.I right\^
  1536. Xset of characters used to move right one resolution unit
  1537. X(Hor) in plot mode, if any.
  1538. X.TP 10
  1539. X.I left\^
  1540. Xset of characters used to move left one resolution unit
  1541. X(Hor) in plot mode, if any.
  1542. X.TP 10
  1543. X.I codetab\^
  1544. Xdefinition of characters needed to print an
  1545. X.I nroff\^
  1546. Xcharacter
  1547. Xon the terminal.
  1548. XThe first byte is the number of character units (Char) needed to hold the
  1549. Xcharacter; i.e., ``\\001'' is one unit wide, ``\\002'' is two
  1550. Xunits wide, etc.  The high-order bit (0200) is on if
  1551. Xthe character is to be underlined in underline mode
  1552. X(.ul).
  1553. XThe rest of the bytes are the characters used to produce the character in
  1554. Xquestion.  If the character has the sign (0200) bit on,
  1555. Xit is a code to move the terminal in plot mode.  It is
  1556. Xencoded as:
  1557. X.RS
  1558. X.IP "0100 bit on" 15
  1559. Xvertical motion.
  1560. X.IP "0100 bit off" 15
  1561. Xhorizontal motion.
  1562. X.IP "040 bit on" 15
  1563. Xnegative (up or left) motion.
  1564. X.IP "040 bit off" 15
  1565. Xpositive (down or right) motion.
  1566. X.IP "037 bits" 15
  1567. Xnumber of such motions to make.
  1568. X.RE
  1569. X.TP 10
  1570. X.I zzz\^
  1571. Xa zero terminator at the end.
  1572. X.PP
  1573. XAll quantities which are in units of fractions of an inch should
  1574. Xbe expressed as
  1575. X.RI INCH* num / denom ,
  1576. Xwhere
  1577. X.I num\^
  1578. Xand
  1579. X.I denom\^
  1580. Xare respectively the numerator and denominator of the fraction; i.e.,
  1581. X1/48 of an inch would be written as ``INCH/48''.
  1582. X.PP
  1583. XIf any sequence of characters does not pertain to the output device,
  1584. Xthat sequence should be given as a null string.
  1585. X.PP
  1586. XIf you have source license:
  1587. X.br
  1588. XThe source code for the terminal
  1589. X.I name\^
  1590. Xis in
  1591. X.BI /usr/src/cmd/text/roff.d/terms.d/tab name .c.
  1592. XWhen a new terminal type is added, the file
  1593. X.I maketerms.c\^
  1594. Xshould be updated to `#include' the source to that driving table;
  1595. Xnote that the various terminal types are grouped into ``parts'' labelled
  1596. X.BR PART1 ,
  1597. X.BR PART2 ,
  1598. Xand
  1599. X.BR PART3 .
  1600. XIf necessary, more parts can be added.  Other changes necessary to
  1601. X.I maketerms.c\^
  1602. Xare left as an exercise to the reader.
  1603. XThe makefile
  1604. X.I terms.mk\^
  1605. Xin that directory should then be updated.
  1606. X.PP
  1607. XIf you do not have source license, but have Bruce Townsend's
  1608. X.I table\^
  1609. Xutility:
  1610. X.br
  1611. XThe source code for the terminal
  1612. X.I name\^
  1613. Xis in a file called
  1614. X.BI tab name .c.
  1615. XWhen a new terminal type is added, the file
  1616. X.I Makefile\^
  1617. Xin the same directory should be updated.
  1618. XJust add the name
  1619. X.BI tab name
  1620. Xto the definition of
  1621. X.BR TABFILES .
  1622. XThen type
  1623. X.BI "make tab" name.
  1624. XStore the result in
  1625. X.B /usr/lib/term.
  1626. X.SH FILES
  1627. X/usr/lib/term/tab\f2name\fP    driving tables
  1628. X.br
  1629. Xtab\f2name\fP.c    source for driving tables
  1630. X.SH SEE ALSO
  1631. Xtroff(1), term(7)
  1632. SHAR_EOF
  1633. if test 6192 -ne "`wc -c 'term.5'`"
  1634. then
  1635.     echo shar: error transmitting "'term.5'" '(should have been 6192 characters)'
  1636. fi
  1637. echo shar: extracting "'term.h'" '(800 characters)'
  1638. if test -f 'term.h'
  1639. then
  1640.     echo shar: over-writing existing file "'term.h'"
  1641. fi
  1642. sed 's/^X//' << \SHAR_EOF > 'term.h'
  1643. X#ifndef    INCH
  1644. X#define    INCH    240
  1645. X#endif
  1646. X
  1647. Xstruct t {
  1648. X    int bset;
  1649. X    int breset;
  1650. X    int Hor;
  1651. X    int Vert;
  1652. X    int Newline;
  1653. X    int Char;
  1654. X    int Em;
  1655. X    int Halfline;
  1656. X    int Adj;
  1657. X    char *twinit;
  1658. X    char *twrest;
  1659. X    char *twnl;
  1660. X    char *hlr;
  1661. X    char *hlf;
  1662. X    char *flr;
  1663. X    char *bdon;
  1664. X    char *bdoff;
  1665. X    char *iton;
  1666. X    char *itoff;
  1667. X    char *ploton;
  1668. X    char *plotoff;
  1669. X    char *up;
  1670. X    char *down;
  1671. X    char *right;
  1672. X    char *left;
  1673. X    char *codetab[256-32];
  1674. X    char *zzz;
  1675. X    };
  1676. X
  1677. Xstruct t_stor {        /* This structure will be stored in the tab file */
  1678. X    int bset;
  1679. X    int breset;
  1680. X    int Hor;
  1681. X    int Vert;
  1682. X    int Newline;
  1683. X    int Char;
  1684. X    int Em;
  1685. X    int Halfline;
  1686. X    int Adj;
  1687. X    int twinit;
  1688. X    int twrest;
  1689. X    int twnl;
  1690. X    int hlr;
  1691. X    int hlf;
  1692. X    int flr;
  1693. X    int bdon;
  1694. X    int bdoff;
  1695. X    int iton;
  1696. X    int itoff;
  1697. X    int ploton;
  1698. X    int plotoff;
  1699. X    int up;
  1700. X    int down;
  1701. X    int right;
  1702. X    int left;
  1703. X    int codetab[256-32];
  1704. X    int zzz;
  1705. X};
  1706. SHAR_EOF
  1707. if test 800 -ne "`wc -c 'term.h'`"
  1708. then
  1709.     echo shar: error transmitting "'term.h'" '(should have been 800 characters)'
  1710. fi
  1711. #    End of shell archive
  1712. exit 0
  1713.